/**
 * 
 */
package com.tma.customlistview.xml;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * @author tqthe
 * 
 */
public class XmlLoader {
    /**
     * Given a string representation of a URL, sets up a connection and gets an
     * input stream.
     * 
     * @param urlString
     * @return
     * @throws IOException
     */
    public static InputStream loadXml(String urlString) throws IOException {
        URL url = new URL(urlString);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setReadTimeout(10000 /* milliseconds */);
        conn.setConnectTimeout(15000 /* milliseconds */);
        conn.setRequestMethod("GET");
        conn.setDoInput(true);

        // starts the query
        conn.connect();
        InputStream stream = conn.getInputStream();
        return stream;
    }
}
